package com.lanyou.esb.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.Repository;
import org.springframework.data.rest.core.annotation.RestResource;

import com.lanyou.esb.entity.ClusterNode;

public interface ClusterNodeRepository extends Repository<ClusterNode, String>, JpaSpecificationExecutor<ClusterNode> {

	long count();
	
	boolean exists(String id);
	
	@RestResource(exported = true)
//	@RequiresPermissions(value={"clusterNode:maintain"})
	<S extends ClusterNode> S save(S entity);	// could expose REST API
	
	<S extends ClusterNode> List<S> save(Iterable<S> entities);
	
	@RestResource(exported = true)
	ClusterNode findOne(String id);	// could expose REST API
	
	ClusterNode getOne(String id);
	
	// 以下三个接口只能选一个暴露为REST API
	
	@RestResource(exported = false)
	List<ClusterNode> findAll();	// could expose REST API
	
	@RestResource(exported = false)
	List<ClusterNode> findAll(Sort sort);	// could expose REST API
	
	@RestResource(exported = true)
//	@RequiresPermissions(value={"clusterNode:view","clusterNode:maintain"},logical=Logical.OR)
	Page<ClusterNode> findAll(Pageable pageable);	// could expose REST API
	
	List<ClusterNode> findAll(Iterable<String> ids);
	
	// 以下两个接口，要么都暴露为REST API，要么都不暴露
	@RestResource(exported = true)
//	@RequiresPermissions(value={"clusterNode:maintain"})
	void delete(String id);	// could expose REST API
	
	@RestResource(exported = true)
//	@RequiresPermissions(value={"clusterNode:maintain"})
	void delete(ClusterNode entity);	// could expose REST API
	
	void delete(Iterable<? extends ClusterNode> entities);
	
	void deleteAll();
	
	void flush();
	
	<S extends ClusterNode> S saveAndFlush(S entity);
	
	void deleteInBatch(Iterable<ClusterNode> entities);
	
	void deleteAllInBatch();
	
	@RestResource(exported = false)
	ClusterNode findByName(String name);
	
	@RestResource(exported = false)
	ClusterNode findByIpaddr(String ipaddr);
	
	@RestResource(exported = false)
	ClusterNode findById(String id);
	
}
